//
//  UIImageView+RBAdd.m
//  ocCrazy
//
//  Created by Lan on 2017/5/16.
//  Copyright © 2017年 SummerTea. All rights reserved.
//

#import "UIImageView+RBAdd.h"
#import "UIImageView+WebCache.h"
#import <UIImage+YYAdd.h>
#import "RBURLConfig.h"

@implementation UIImageView(RBAdd)

- (UIImage *)defaultImage
{
    static UIImage *defaultImage = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        defaultImage = [UIImage imageWithColor:[UIColor colorWithWhite:0.98 alpha:1]];
    });
    return defaultImage;
}

- (void)setImageWithUrl:(NSString *)imgUrl placeHolder:(NSString *)placeHolderName
{
    if (![imgUrl isKindOfClass:[NSString class]])
    {

        self.image = placeHolderName.length? [UIImage imageNamed:placeHolderName]: [self defaultImage];
        return;
    }
    
    NSString *url = [RBURLConfig adjustImageUrl:imgUrl];
    [self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[self defaultImage]];
}

- (void)setImageWithUrl:(NSString *)imgUrl placeHolder:(NSString *)placeHolderName type:(NSInteger)type
{
    
}

@end
